<?php
require_once ('password.php');
require_once('accounts.php');
require_once('facebook.php');
function GetConnection()
{
	global $password, $username, $schema, $localhost;
	
	$connect = new mysqli( $localhost, $username, $password, $schema );
	if($connect->error)
	{
		throw new Exception($connect->error, 1);
	}
	return $connect;
}
function EscapeRow($row, $connect) {
	$arr = array();
	foreach ($row as $key => $value) {
		$arr[$key] = $connect->real_escape_string($value);
	}
	return $arr;
}

function mysql_prep( $value ) {
		$magic_quotes_active = get_magic_quotes_gpc();
		$new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0
		if( $new_enough_php ) { // PHP v4.3.0 or higher
			// undo any magic quote effects so mysql_real_escape_string can do the work
			if( $magic_quotes_active ) { $value = stripslashes( $value ); }
			$value = mysql_real_escape_string( $value );
		} else { // before PHP v4.3.0
			// if magic quotes aren't already on then add slashes manually
			if( !$magic_quotes_active ) { $value = addslashes( $value ); }
			// if magic quotes are active, then the slashes already exist
		}
		return $value;
	}
function redirect_to( $location = NULL ) {
	if ($location != NULL) {
		header("Location: {$location}");
		die();
	}
}

function GetKeywords()
{
	$conn = GetConnection();
	return $conn->query('SELECT * FROM Psi_Keywords K ');
}

	//Facebook Login
	$facebook = new Facebook(array(
		'appId' => $appId,
		'secret' => $appSecret
	));
	
	$fbUser = $facebook->getUser();
	
	//$user = $facebook->api("/me");

	//echo $facebook->getAccessToken();
